package org.itboys.mobile.entity.mysql.order;

import org.apache.commons.lang.StringUtils;
import org.itboys.commons.utils.tools.LongUtil;
import org.itboys.mongodb.entity.BaseMySqlEntity;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created on 2017/10/20.
 * @author 朱坤涛
 */
public class PearlOrder extends BaseMySqlEntity{
    private String orderNo; //订单编号
    private Long agentId; //代理商Id
    private String agentName;
    private String agentPhone;
    private String agentAddress;
    private Map<String,Object> agent;

    private Long shopId; //门店
    private String shopName;
    private String shopPhone;
    private String shopAddress;
    private Map<String,Object> shop;

    private Long memberId; //下单用户Id
    private Long recommenderId; //推荐人Id
    private String recommenderName;
    private String recommenderPhone;
    private String recommenderAddress;

    private Map<String,Object> recommender;//推荐人
    private Long recommendeAgentId; //推荐代理商Id
    private String recommendeAgentName;
    private String recommendeAgentPhone;
    private String recommendeAgentAddress;
    private Map<String,Object> recommendeAgent;//推荐代理商
    private Long recommendeShopId;//推荐门店ID
    private String recommendeShopName;
    private String recommendeShopPhone;
    private String recommendeShopAddress;
    private Map<String,Object> recommendeShop;//推荐门店

    private String receiveAddress; //收货地址
    private String receiveName;//收货人
    private String receivePhone;//收货电话

    //收货地址查询参数
    private Long provinceId;
    private Long cityId;
    private Long districtId;

    private String expressNo; //快递单号
    private String expressCompany;//快递公司
    private String expressCompanyNo;//快递公司代码
    private Integer orderStatus; //订单状态

    //关于金额
    private Integer payType;

    private String scale;
    private BigDecimal totalAmount; //订单应付金额
    private BigDecimal payAmount; //订单实付金额
    private BigDecimal deductionAmount; //订单免减金额
    private BigDecimal usedBalance; //账户余额支付金额
    private BigDecimal freight;//运费
    private BigDecimal agentRebate;//代理商佣金。需要计算存储（配送+成本）
    private BigDecimal shopRebate;//门店佣金。需要计算存储（配送+成本）
    private BigDecimal recommenderRebate;//推荐佣金，创客或门店或代理商推荐。需要计算存储.
    private BigDecimal recommendeAgentRebate;//推荐代理商佣金，代理商推荐。需要计算存储.
    private BigDecimal recommendeShopRebate;//推荐门店佣金，门店推荐。需要计算存储.
    private BigDecimal memberSelftRebate;//下单用户自己的佣金。如果下单用户没有推荐人，没有推荐门店，没有推荐代理商。则下单用户自己拿推荐佣金

    //实际需要展示佣金。不存储，根据传入用户Id实时计算,决定用户佣金在本个订单中是多少.
    private BigDecimal memberRebate;//

    private Date creatTime;//创建时间
    private Date payTime;//付款时间
    private Date sendTime;//发货时间
    private Date receiveTime;//收货时间
    private Date commentTime;//评论时间
    //订单商品
    private List<PearlOrderProduct> orderProducts;
    // private Long returnTime;//评论时间
    private String remark;//备注拆单的信息：发货商家，联系电话，快递公司,快递单号
    private Long parentOrderId;//拆分订单后，原订单ID.//2016年7月7日废弃
    private String aliPayAmount;//支付宝支付金额。统计使用
    private BigDecimal bankPayAmount;//银行卡支付金额，统计使用

    public PearlOrder() {
    }

    public PearlOrder(Long agentId, Long shopId) {
        this.agentId = agentId;
        this.shopId = shopId;
    }

    public String getOrderNo() {
        return orderNo;
    }
    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }
    public Long getAgentId() {
        return agentId;
    }
    public void setAgentId(Long agentId) {
        this.agentId = agentId;
    }
    public Map<String, Object> getAgent() {

        return agent;
    }


    public void setAgent(Map<String, Object> agent) {
        agent.put("id", LongUtil.isNotZreo(agentId)?agentId:0L);
        agent.put("name",StringUtils.isNotEmpty(shopName)?shopName:"");
        agent.put("phone", StringUtils.isNotEmpty(agentPhone)?agentPhone:"");
        agent.put("fullAddress", StringUtils.isNotEmpty(agentAddress)?agentAddress:"");

        this.agent = agent;
    }

    public Long getShopId() {
        return shopId;
    }
    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }
    public Map<String, Object> getShop() {
        return shop;
    }
    public void setShop(Map<String, Object> shop) {
        shop.put("id",LongUtil.isNotZreo(shopId)?shopId:0L);
        shop.put("name", StringUtils.isNotEmpty(shopName)?shopName:"");
        shop.put("phone", StringUtils.isNotEmpty(shopPhone)?shopPhone:"");
        shop.put("fullAddress", StringUtils.isNotEmpty(shopAddress)?shopAddress:"");

        this.shop = shop;
    }
    public Long getMemberId() {
        return memberId;
    }
    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Long getRecommenderId() {
        return recommenderId;
    }
    public void setRecommenderId(Long recommenderId) {
        this.recommenderId = recommenderId;
    }
    public Map<String, Object> getRecommender() {
        return recommender;
    }

    public void setRecommender(Map<String, Object> recommender) {
        recommender.put("id",LongUtil.isNotZreo(recommenderId)?recommenderId:0L);
        recommender.put("name", StringUtils.isNotEmpty(recommenderName)?recommenderName:"");
        recommender.put("phone", StringUtils.isNotEmpty(recommenderPhone)?recommenderPhone:"");
        recommender.put("fullAddress", StringUtils.isNotEmpty(recommenderAddress)?recommenderAddress:"");

        this.recommender = recommender;
    }

    public Long getRecommendeAgentId() {
        return recommendeAgentId;
    }
    public void setRecommendeAgentId(Long recommendeAgentId) {
        this.recommendeAgentId = recommendeAgentId;
    }
    public Long getRecommendeShopId() {
        return recommendeShopId;
    }
    public void setRecommendeShopId(Long recommendeShopId) {
        this.recommendeShopId = recommendeShopId;
    }
    public String getReceiveAddress() {
        return receiveAddress;
    }
    public void setReceiveAddress(String receiveAddress) {
        this.receiveAddress = receiveAddress;
    }
    public String getReceiveName() {
        return receiveName;
    }
    public void setReceiveName(String receiveName) {
        this.receiveName = receiveName;
    }
    public String getReceivePhone() {
        return receivePhone;
    }
    public void setReceivePhone(String receivePhone) {
        this.receivePhone = receivePhone;
    }


    public Long getProvinceId() {
        return provinceId;
    }
    public void setProvinceId(Long provinceId) {
        this.provinceId = provinceId;
    }
    public Long getCityId() {
        return cityId;
    }
    public void setCityId(Long cityId) {
        this.cityId = cityId;
    }
    public Long getDistrictId() {
        return districtId;
    }
    public void setDistrictId(Long districtId) {
        this.districtId = districtId;
    }
    public String getExpressNo() {
        return expressNo;
    }
    public void setExpressNo(String expressNo) {
        this.expressNo = expressNo;
    }
    public String getExpressCompany() {
        return expressCompany;
    }
    public void setExpressCompany(String expressCompany) {
        this.expressCompany = expressCompany;
    }
    public String getExpressCompanyNo() {
        return expressCompanyNo;
    }
    public void setExpressCompanyNo(String expressCompanyNo) {
        this.expressCompanyNo = expressCompanyNo;
    }
    public Integer getOrderStatus() {
        return orderStatus;
    }

    //返回订单状态字符串
    public String  getOrderStatusStr(){
        String orderStatusStr ="";
        switch (this.orderStatus) {
            case 0:
                orderStatusStr= "待付款";
                break;
            case 1:
                orderStatusStr= "待发货";
                break;
            case 2:
                orderStatusStr= "配送中";
                break;
            case 3:
                orderStatusStr= "已签收";
                break;
            case 4:
                orderStatusStr= "已评价";
                break;
            case 5:
                orderStatusStr= "已删除";
                break;
            case 6:
                orderStatusStr= "待退款";
                break;
            case 7:
                orderStatusStr= "已退款";
                break;
            case 8:
                orderStatusStr= "待退货";
                break;
            case 9:
                orderStatusStr= "已退货";
                break;
            default:
                break;
        }
        return orderStatusStr;
    }
    public void setOrderStatus(Integer orderStatus) {
        this.orderStatus = orderStatus;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }
    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }
    public BigDecimal getPayAmount() {
        return payAmount;
    }
    public void setPayAmount(BigDecimal payAmount) {
        this.payAmount = payAmount;
    }
    public BigDecimal getDeductionAmount() {
        return deductionAmount;
    }
    public void setDeductionAmount(BigDecimal deductionAmount) {
        this.deductionAmount = deductionAmount;
    }

    public BigDecimal getFreight() {
        return freight;
    }
    public BigDecimal getUsedBalance() {
        return usedBalance;
    }
    public void setUsedBalance(BigDecimal usedBalance) {
        this.usedBalance = usedBalance;
    }

    public void setFreight(BigDecimal freight) {
        this.freight = freight;
    }

    public BigDecimal getAgentRebate() {
        return agentRebate;
    }
    public void setAgentRebate(BigDecimal agentRebate) {
        this.agentRebate = agentRebate;
    }
    public BigDecimal getShopRebate() {
		/*if(shopRebate>0){
			return new BigDecimal(shopRebate).setScale(BigDecimal.ROUND_HALF_UP, 2).BigDecimalValue();
		}*/
        return shopRebate;
    }
    public void setShopRebate(BigDecimal shopRebate) {
        this.shopRebate = shopRebate;
    }


    public BigDecimal getRecommenderRebate() {
        return recommenderRebate;
    }
    public void setRecommenderRebate(BigDecimal recommenderRebate) {
        this.recommenderRebate = recommenderRebate;
    }

    public BigDecimal getRecommendeAgentRebate() {
        return recommendeAgentRebate;
    }
    public void setRecommendeAgentRebate(BigDecimal recommendeAgentRebate) {
        this.recommendeAgentRebate = recommendeAgentRebate;
    }
    public BigDecimal getRecommendeShopRebate() {
        return recommendeShopRebate;
    }
    public void setRecommendeShopRebate(BigDecimal recommendeShopRebate) {
        this.recommendeShopRebate = recommendeShopRebate;
    }


    public BigDecimal getMemberSelftRebate() {
        return memberSelftRebate;
    }
    public void setMemberSelftRebate(BigDecimal memberSelftRebate) {
        this.memberSelftRebate = memberSelftRebate;
    }
    public BigDecimal getMemberRebate() {
        return memberRebate;
    }
    public void setMemberRebate(BigDecimal memberRebate) {
        this.memberRebate = memberRebate;
    }
    public Date getPayTime() {
        return payTime;
    }
    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }
    public Date getSendTime() {
        return sendTime;
    }
    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }
    public Date getReceiveTime() {
        return receiveTime;
    }
    public void setReceiveTime(Date receiveTime) {
        this.receiveTime = receiveTime;
    }
    public Date getCommentTime() {
        return commentTime;
    }
    public void setCommentTime(Date commentTime) {
        this.commentTime = commentTime;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public List<PearlOrderProduct> getOrderProducts() {
        return orderProducts;
    }
    public void setOrderProducts(List<PearlOrderProduct> orderProducts) {
        this.orderProducts = orderProducts;
    }
    public Long getParentOrderId() {
        return parentOrderId;
    }
    public void setParentOrderId(Long parentOrderId) {
        this.parentOrderId = parentOrderId;
    }
    public Map<String, Object> getRecommendeAgent() {
        return recommendeAgent;
    }
    public void setRecommendeAgent(Map<String, Object> recommendeAgent) {
        recommendeAgent.put("id",LongUtil.isNotZreo(recommendeAgentId)?recommendeAgentId:0L);
        recommendeAgent.put("name", StringUtils.isNotEmpty(recommendeAgentName)?recommendeAgentName:"");
        recommendeAgent.put("phone", StringUtils.isNotEmpty(recommendeAgentPhone)?recommendeAgentPhone:"");
        recommendeAgent.put("fullAddress", StringUtils.isNotEmpty(recommendeAgentAddress)?recommendeAgentAddress:"");

        this.recommendeAgent = recommendeAgent;
    }
    public Map<String, Object> getRecommendeShop() {
        return recommendeShop;
    }
    public void setRecommendeShop(Map<String, Object> recommendeShop) {
        recommendeShop.put("id",LongUtil.isNotZreo(recommendeShopId)?recommendeShopId:0L);
        recommendeShop.put("name", StringUtils.isNotEmpty(recommendeShopName)?recommendeShopName:"");
        recommendeShop.put("phone", StringUtils.isNotEmpty(recommendeShopPhone)?recommendeShopPhone:"");
        recommendeShop.put("fullAddress", StringUtils.isNotEmpty(recommendeShopAddress)?recommendeShopAddress:"");

        this.recommendeShop = recommendeShop;
    }

    public String getAgentName() {
        return agentName;
    }
    public void setAgentName(String agentName) {
        this.agentName = agentName;
    }
    public String getAgentPhone() {
        return agentPhone;
    }
    public void setAgentPhone(String agentPhone) {
        this.agentPhone = agentPhone;
    }
    public String getAgentAddress() {
        return agentAddress;
    }
    public void setAgentAddress(String agentAddress) {
        this.agentAddress = agentAddress;
    }
    public String getShopName() {
        return shopName;
    }
    public void setShopName(String shopName) {
        this.shopName = shopName;
    }
    public String getShopPhone() {
        return shopPhone;
    }
    public void setShopPhone(String shopPhone) {
        this.shopPhone = shopPhone;
    }
    public String getShopAddress() {
        return shopAddress;
    }
    public void setShopAddress(String shopAddress) {
        this.shopAddress = shopAddress;
    }
    public String getRecommenderName() {
        return recommenderName;
    }
    public void setRecommenderName(String recommenderName) {
        this.recommenderName = recommenderName;
    }
    public String getRecommenderPhone() {
        return recommenderPhone;
    }
    public void setRecommenderPhone(String recommenderPhone) {
        this.recommenderPhone = recommenderPhone;
    }
    public String getRecommenderAddress() {
        return recommenderAddress;
    }
    public void setRecommenderAddress(String recommenderAddress) {
        this.recommenderAddress = recommenderAddress;
    }
    public String getRecommendeAgentName() {
        return recommendeAgentName;
    }
    public void setRecommendeAgentName(String recommendeAgentName) {
        this.recommendeAgentName = recommendeAgentName;
    }
    public String getRecommendeAgentPhone() {
        return recommendeAgentPhone;
    }
    public void setRecommendeAgentPhone(String recommendeAgentPhone) {
        this.recommendeAgentPhone = recommendeAgentPhone;
    }
    public String getRecommendeAgentAddress() {
        return recommendeAgentAddress;
    }
    public void setRecommendeAgentAddress(String recommendeAgentAddress) {
        this.recommendeAgentAddress = recommendeAgentAddress;
    }
    public String getRecommendeShopName() {
        return recommendeShopName;
    }
    public void setRecommendeShopName(String recommendeShopName) {
        this.recommendeShopName = recommendeShopName;
    }
    public String getRecommendeShopPhone() {
        return recommendeShopPhone;
    }
    public void setRecommendeShopPhone(String recommendeShopPhone) {
        this.recommendeShopPhone = recommendeShopPhone;
    }
    public String getRecommendeShopAddress() {
        return recommendeShopAddress;
    }
    public void setRecommendeShopAddress(String recommendeShopAddress) {
        this.recommendeShopAddress = recommendeShopAddress;
    }

    public String getAliPayAmount() {
        return aliPayAmount;
    }

    public void setAliPayAmount(String aliPayAmount) {
        this.aliPayAmount = aliPayAmount;
    }

    public BigDecimal getBankPayAmount() {
        return bankPayAmount;
    }

    public void setBankPayAmount(BigDecimal bankPayAmount) {
        this.bankPayAmount = bankPayAmount;
    }
    public Integer getPayType() {return payType;}
    public void setPayType(Integer payType) {this.payType = payType;}

    public Date getCreatTime() {return creatTime;}

    public void setCreatTime(Date creatTime) {this.creatTime = creatTime;}

    public String getScale() {
        return scale;
    }

    public void setScale(String scale) {
        this.scale = scale;
    }
}
